//
//  344. 反转字符串.swift
//  LeetCodeTrain
//
//  Created by rjb on 2021/7/10.
//  Copyright © 2021 rjb. All rights reserved.
//

import Foundation
class Solution344 {
    // 反转字符串
    // 前后两两交换就可以了
    func reverseString(_ s: inout [Character]) {
        var pre: Int = 0
        var post: Int = s.count - 1
        while pre < post {
            let tmp = s[pre]
            s[pre] = s[post]
            s[post] = tmp
            pre += 1
            post -= 1
        }
    }
    static func test() {
        let solution = Solution344()
        var nums: [Character] = ["h","e","l","l","o"]
        solution.reverseString(&nums)
        print(nums)
    }
}
